#include <bits/stdc++.h>
// 2025/01/28
// tag:
// Author: Zhang Muen
using namespace std;

int n, m;
int is_prime[1000001];

void init()
{
    for (int i = 2; i <= m; i++)
        is_prime[i] = 1;
    for (int i = 2; i <= sqrt(m) + 1; i++) {
        if (is_prime[i]) {
            for (int j = i * i; j <= m; j += i)
                is_prime[j] = 0;
        }
    }
    for (int i = 2; i <= m; i++)
        is_prime[i] += is_prime[i - 1];
}

signed main()
{
    cin >> n >> m;
    init();
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        if (r > m || l < 1)
            cout << "Crossing the line" << endl;
        else
            cout << is_prime[r] - is_prime[l - 1] << endl;
    }
    return 0;
}